import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
//引入登录页
import Login from '../views/Login.vue'
import PostList from '../views/PostList'
import EditPost from '../views/EditPost'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    children: [
      {
        // 嵌套子路由 path 无需斜杠
        path: 'postlist',
        component: PostList
      },
      {
        path: 'editpost',
        component: EditPost
      }
    ]
  },
  {
    path: '/login',
    name: 'LoginPage',
    component: Login
  }
]

const router = new VueRouter({
  routes
})

export default router
